import http, { request } from '@/utils/http'
import { OrderListParams, OrderDetailParams, OrderDeliveryParams, OrderExportParams } from './model/orderModel'

// 获取订单列表
export function getOrderList(data: OrderListParams) {
  return request({
    url: '/order/getAll',
    method: 'post',
    data,
  })
}

// 获取待处理订单列表
export function getPendingOrderList(data: OrderListParams) {
  return request({
    url: '/order/getAll',
    method: 'post',
    data,
  })
}

// 获取已完成订单列表
export function getCompletedOrderList(data: OrderListParams) {
  return request({
    url: '/order/getAll',
    method: 'post',
    data,
  })
}

// 获取售后订单列表
export function getAfterOrderList(data: OrderListParams) {
  return request({
    url: '/after/getAll',
    method: 'post',
    data,
  })
}

// 获取订单详情
export function getOrderDetail(data: OrderDetailParams) {
  return request({
    url: '/order/getById',
    method: 'post',
    data,
  })
}

// 获取快递公司列表
export function getExpressCompanyList(data?: any) {
  return request({
    url: '/express/getExpressSelect',
    method: 'post',
    data,
  })
}

// 订单发货
export function deliveryOrder(data: OrderDeliveryParams) {
  return request({
    url: '/order/delivery',
    method: 'post',
    data,
  })
}

// 导出订单
export function exportOrder(data: OrderExportParams) {
  return request({
    url: '/order/export',
    method: 'post',
    data,
    responseType: 'blob',
  })
}

// 导出待处理订单
export function exportPendingOrder(data: OrderExportParams) {
  return request({
    url: '/order/export',
    method: 'post',
    data,
    responseType: 'blob',
  })
}

// 导出已完成订单
export function exportCompletedOrder(data: OrderExportParams) {
  return request({
    url: '/order/export',
    method: 'post',
    data,
    responseType: 'blob',
  })
}

// 导出售后订单
export function exportAfterOrder(data: OrderExportParams) {
  return request({
    url: '/order/export',
    method: 'post',
    data,
    responseType: 'blob',
  })
}

// 处理售后订单
export function handleAfterOrder(data: { id: string }) {
  return request({
    url: '/order/handle',
    method: 'post',
    data,
  })
}
